/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_RTP_TCP_CLIENT_H
#define MK_RTP_TCP_CLIENT_H
#include "MkTcp/MkTcpClient.h"
#include "MkRtp.h"

class MkApi CMkRtpTcpClient : public CMkTcpClient, public CMkRtp
{
public:
    CMkRtpTcpClient(CMkEvent* pEvent, CMkTimer* pTimer,const MkEventRemovedCallback& RemovedCb);
    ~CMkRtpTcpClient();

    Uint32 Start(const Uint16& TcpPort);
    Uint32 DeleteRemoter(const Uint32& Ssrc) override;
    Uint32 SendRtpPacket(const CMkRtpPacket& RtpPacket, const MkString& RemoteIp, Uint16 RemotePort) override;
    Uint32 SendRtcpPacket(const CMkRtcpPacket& RtcpPacket, const MkString& RemoteIp, Uint16 RemotePort) override;
    Uint32 Release() override;
protected:
    Uint32 OnRecv() override;
    Uint32 OnEventRemoved() override;
    Uint32 OnConnect() override;
private:
    Uint32 ParsePacket(Uint8* pBuf, Uint32 nLen);
private:
    Uint8*              m_pRecvBuffer;
    Uint32              m_nMaxLen;
    Uint32              m_nOffset;
};


#endif